<?php
include_once("class_mysql.php");

mysql_query("set names utf8");

for($i=0;$i<10;$i++)
{
	$realname = $_POST['name'.$i];
	$grade = $_POST['grade'.$i];
	$branch = $_POST['branch'.$i];
	if($realname =='')
	{
		exit('you must input name');
	}
	if($grade =='')
	{
		exit('you must input grade');
	}
	if($branch =='')
	{
		exit('you must input branch');
	}
	if(is_uploaded_file($_FILES['upfile'.$i]['tmp_name'])){

		//print_r($_FILES["upfile"]);
		$upfile = $_FILES["upfile".$i];
		print_r($upfile);
		$name = time().$upfile["name"];
		$type = $upfile["type"];
		$size = $upfile["size"];
		if($size < 1)
		{
			exit('which your picture??');
		}
		$tmp_name = $upfile["tmp_name"];
		echo $tmp_name;
		$time = time();

		$sql = "INSERT INTO `litianle_fm_man`.`top_man` (`sid` ,`name` ,`show` ,`grade` ,`branch` ,`win` ,`lose` ,`winper` ,`dateline`)
		VALUES (NULL , '$realname', '$name', '$grade', '$branch', '0', '0', '0','$time')";

		echo "$sql";
		$result = mysql_query($sql);

		switch($type){
			case 'image/pjpeg' : $ok=1;
			break;
			case 'image/jpeg' : $ok=1;
			break;
			case 'image/gif' : $ok=1;
			break;
			case 'image/png' : $ok=1;
			break;
			case 'image/x-png' : $ok=1;
			break;
		}
		if($ok){
			move_uploaded_file($tmp_name,'show/'.$name);
		}
		echo "恭喜了，上傳成功了耶~！！";

	}

}

?>
<br><a href="upp.php"> 点击这里返回刚才页面 </a>

<br>
<br>



